<template>
    <div class="app-container">
        <uc-table url="admin/user/getUserPage" name="用户" ref="userTable" pageable table-border :search-form="searchForm">
            <template slot="searchForm" @selection-change="handleSelectionChange" row-key="ucId">
                <el-form size="mini" :inline="true" :model="searchForm" class="demo-form-inline filter-container">
                    <!--搜索输入框-->
                    <el-form-item>
                        <el-input type="text" v-model="searchForm.name" placeholder="请输入姓名" clearable @clear="clearInput()"></el-input>
                    </el-form-item>
                    <!--搜索按钮--新增按钮-->
                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search" class="filter-item" @click="handleSearch()">查询</el-button>
                        <el-button type="primary" icon="el-icon-search" class="filter-item" @click="batchInput(checked)">批量登记</el-button>
                    </el-form-item>
                </el-form>
            </template>
            <template slot="columns">
                <el-table-column type="selection" width="55" :reserve-selection="true"></el-table-column>
                <el-table-column prop="name" label="姓名" align="left" :show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="mobile" label="电话" align="left" show-overflow-tooltip ></el-table-column>
                <el-table-column prop="sex" label="性别" align="left" >
                    <template slot-scope="scope">
                        {{scope.row.sex | formDateSex}}
                    </template>
                </el-table-column>
                <el-table-column prop="address" label="操作" width="220" align="left" class-name="small-padding fixed-width">
                    <template>
                        <el-button size="mini" icon="el-icon-edit" type="primary" @click="startWork()">登记</el-button>
                    </template>
                </el-table-column>
            </template>
        </uc-table>
    </div>
</template>

<script>
import UcTable from "@/components/UcTable/index.vue";
import {batchInput} from "@/api/common";

export default {
    name: "userList",
    components: {UcTable},
    data(){
        return{
            searchForm:{
                deleted:false,

            },
            deleteLoading:false,
            checked:[],
            workUserList:[],
        }
    },
    created() {

    },
    methods:{
        handleSearch(){
            this.$refs.userTable.getTableData(1)
        },
        handleEdit(val){
            this.$router.push("/sys/useredit/"+val.ucId)
        },
        clearInput(){
            //清除输入框
            this.searchForm.name = null
            this.handleSearch()
        },
        batchInput(rows){
            rows.forEach(user => {
                console.log(user)
                console.log(user.ucId)
                this.workUserList.push(user.ucId)

            })
            console.log(this.workUserList)
            // batchInput({workUserList: this.workUserList}).then(res => {
            //     this.handleSearch()
            //     console.log(res)
            // }).catch(error => {
            //     console.log(error)
            // })
        },
        //上班时间
        startWork(){
            console.log(new Date()+"上班")
        },
        handleSelectionChange(val){
            console.log("handleSelectionChange" + val)
            this.checked = val
            console.log("checked" + this.checked)
        }


    }
}
</script>

<style scoped>

</style>